#include ("/_includes/_layout.html")
#define css()
<style type="text/css">
.nav-tabs li{width:200px;}
.app-image-list li {
    background-color: #fff;
    border: 1px solid #ddd;
    display: block;
    float: left;
    height: 40px;
    margin: 0 10px 10px 0;
    position: relative;
    width: 40px;
}
 .app-image-list li a {
    display: block;
    height: 100%;
}
.app-image-list li img {
    height: 100%;
    width: 100%;
}
.app-image-list li .add-goods, .app-image-list li .add {
    cursor: pointer;
    display: inline-block;
    height: 100%;
    line-height: 40px;
    text-align: center;
    width: 100%;
}
.app-image-list li:hover .close-modal {
    display: block;
}
</style>
#end
#@layout("限时打折", "wxmall,点步科技", "Wxmall社区","wxmall") 
#define content()
<div class="wrapper wrapper-content">
	<div class="ibox">
		<div class="ibox-content active_statistics">
		<!-- <div class="ibox-title">
			<small><a href="#(webctx)/promotion">《返回列表</a></small>
		</div> -->
			<div class="title_query padtop">
				<form id="promotionForm" class="form-horizontal">
					<input type="hidden" name="id" id="id" value="#(promotion.promotionId??)"/>
					<div class="form-group">
			            <label class="col-md-2 control-label">折扣活动名称<span style="color: red;"><em>*</em></span></label>
			            <div class="col-md-8" id="error_promotion_name">
			                <input id="promotion_name" name= "promotion_name" value="#(promotion.promotionName??)" maxlength="20" type="text" class="form-control" style="width: 400px" >
			                <label class="control-label" for="promotion_name"></label>
			            </div>
			        </div>
			        <div class="form-group">
			            <label class="col-md-2 control-label">生效时间<span style="color: red;"><em>*</em></span></label>
			            <div class="col-sm-9">
		                   	<div class="row">
		                   		<div class="col-md-3" id="error_start_date">
			                        <input type="text" id="start_date" name="start_date" readonly="readonly" style="width: 140px;"
									onfocus="WdatePicker({errDealMode:2, skin:'twoer', isShowClear:false,readOnly:true,dateFmt:'yyyy-MM-dd %H:%m:%s',minDate:'%y-%M-%d %H:%m:%s',maxDate:'#F{$dp.$D(\'end_date\')}'})"
									class="Wdate" value="#date(promotion.startDate??, 'yyyy-MM-dd HH:mm:ss')" />
									<label class="control-label" for="start_date"></label>
			                    </div>
			                    <div class="col-md-3" id="error_end_date">
			                        <input type="text" id="end_date" name="end_date" readonly="readonly" style="width: 140px;"
									onfocus="WdatePicker({errDealMode:2, skin:'twoer', isShowClear:false,readOnly:true,dateFmt:'yyyy-MM-dd %H:%m:%s',minDate:'#F{$dp.$D(\'start_date\',{d:7});}'})"
									class="Wdate" value="#date(promotion.endDate??, 'yyyy-MM-dd HH:mm:ss')"  />	
									<label class="control-label" for="end_date"></label>
			                    </div>	
			                    <div class="col-md-4">
			                    	<a class="label label-default" href="javascript:dateTimeTag(3);">三天</a>
			                    	<a class="label label-default" href="javascript:dateTimeTag(7);">一周</a>
			                    	<a class="label label-default" href="javascript:dateTimeTag(15);">半个月</a>
			                    </div>
			                </div>
			            </div>
			        </div>
			        <div class="form-group">
			            <label class="col-md-2 control-label">活动标签<span style="color: red;"><em>*</em></span></label>
			            <div class="col-md-8" id="error_promotion_tag">
			                <input id="promotion_tag" name="promotion_tag" value="#if(promotion) #(promotion.promotionTag) #else 限时打折  #end" maxlength="20" type="text" class="form-control" style="width: 200px" >
			                <label class="control-label" for="promotion_tag"></label>
			            </div>
			        </div>
			        <!-- <ol class="breadcrumb">
						<li><i class="fa fa-home"></i><a href="javascript:void(0)">选择活动商品</a></li>
					</ol> -->
					<div class="alert alert-danger" style="display: none;" id="zhek_err_msg">
						<strong>错误!</strong> 请设置商品折扣
					</div>
					<div class="tabs-container">
				        <ul id="select_item_tab" class="nav nav-tabs">
				            <li class="active"><a id="select_item_a" href="javascript:void(0)">第一步:选择商品</a></li>
				            <li><a id="set_promotion_a" href="javascript:void(0)">第二步:设置折扣<font color="red" id="_sel_total_item" style="display: none;">(#if(promotion) #(promotion.promotionSets.size()) #else 0 #end)</font></a></li>
				        </ul>
				    </div>
				    <div class="panel-body">
						<div id="myTabContent" class="tab-content">
							<div class="tab-pane active" id="select_items_div">
								<table class="table table-striped table-bordered bootstrap-datatable datatable" id="mainTable" border="0" style="width: 80%">
									<thead>
										<tr>
											<th><input type="checkbox" id="all" title="全选/反选" style="margin-right: 4px; vertical-align: middle;"/></th>
											<th><span style="vertical-align: middle;">&nbsp;&nbsp;商品</span></th>
											<th>价格</th>
											<th>库存</th>
											<!-- <th>操作</th> -->
										</tr>
									</thead>
									<tbody class="productLotGrid">
									</tbody>
								</table>
								<div id="productToolsbar" class="panel-body">
									<div id="pager" class="jqpager" style="margin-bottom: 1px;float: right;"></div>
								</div>
							</div>
							<div class="tab-pane" id="promotion_set_div">
								<div style="float: left; padding-right: 20px;padding-bottom: 10px;">
									<a onclick="batchDazhe()" class="btn btn-primary btn-xs" href="javascript:void(0)">批量打折</a>
									<a onclick="batchJianjia()" class="btn btn-primary btn-xs" href="javascript:void(0)">批量减价</a>
								</div>
								<div id="batch-dazhe" style="display: none;">
									<input id="bc-dazhe" type="text" value="" placeholder="请输入折扣" style="width: 80px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"/> 折
									<a onclick="confirmDazhe()" href="javascript:void(0)">确定</a>&nbsp;&nbsp;<a id="quxiao_dazhe_a" href="javascript:void(0)">取消</a>
								</div>
								<div id="batch-jianjia" style="display: none;float: left;">
									减 <input id="bc-jianjia" type="text" value="" placeholder="请输入价格" style="width: 80px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"/>
									<a onclick="confirmJiage()" href="javascript:void(0)">确定</a>&nbsp;&nbsp;<a id="quxiao_jianjia_a" href="javascript:void(0)">取消</a>								
								</div>
								<table class="table table-striped table-bordered bootstrap-datatable datatable" id="promotionSetTable" border="0" style="width: 80%">
									<tbody class="productSetLotGrid">
										#if(promotion !=null)
											#for(ps:promotion.promotionSets)
												<tr class="package trcls_#(ps.productId)" pp="#(ps.productPrice)" prodId="#(ps.productId)" ptype="#(ps.type)" ps_id="#(ps.id)">
													<!-- <td><input type="checkbox" class="commchk" id="chk_set_#(ps.productId)" style="margin-right: 4px; vertical-align: middle;"/></td> -->
													<td>
														<ul class="js-picture-lists app-image-list"><li><img src="#(ps.productImg)" width="40px" height="40px"></li></ul>
														<p class="goods-price"><font color="red">￥#(ps.productPrice)</font></p>
														<p class="goods-title">#(ps.productName)</p>
													</td>
													<td>
														<div class="input-group dazhe">
													       <span class="input-group-addon">打折</span>
													       <input type="text" value="#(ps.zhekou)" class="form-control" style="width: 70px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')">
														</div>
													</td>
													<td>
														<div class="input-group jianjia">
															<span class="input-group-addon">减价</span>
															<input type="text" value="#(ps.jianjia)" class="form-control" style="width: 70px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')">
														</div>
													</td>
													<td>
														<div class="input-group set_result">
															<span class="input-group-addon">减价后</span>
															<input type="text" value="#(ps.promotionValue)" class="form-control" style="width: 70px;" readonly="readonly">
														</div>
													</td>
													<td><a id="#(ps.productId)" href="javascript:void(0)">取消</a></td>
												</tr>
											#end
										#end
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</form>	
				<div class="panel-footer" align="center">
			   	 	<button onclick="savePromotion();" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i>提交</button>
			   	 	<a href="#(webctx)/promotion" class="btn btn-default btn-sm">取   消</a>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- 选择的商品列表模板 -->
<script type="text/template" id="product_table_tr_tpl">
		<tr class="package">
			<td><input type="checkbox" class="commchk" id="checkbox_{id}" product_id="{id}" product_name="{name}" product_price="{price}" product_img="{img}" style="margin-right: 4px; vertical-align: middle;"/></td>
			<td>
			<ul class="js-picture-lists app-image-list"><li><img src="{img}" width="40px" height="40px"></li></ul>
            <p class="goods-title"><a class="new-window" href="javascript:void(0)" title="{name}">{name}</a></p>
			</td>
			<td><span class="label label-success">￥{price}</span></td>
            <td>{stock}</td>
		</tr>
</script>
<!-- 打折信息设置模板 -->
<script type="text/template" id="promotion_set_tr_tpl">
	<tr class="package trcls_{id}" pp="{price}" prodId="{id}" ptype="">
		<!--<td><input type="checkbox" class="commchk" id="chk_set_{id}" style="margin-right: 4px; vertical-align: middle;"/></td>-->
		<td>
			<ul class="js-picture-lists app-image-list"><li><img src="{img}" width="40px" height="40px"></li></ul>
			<p class="goods-price"><font color="red">￥{price}</font></p>
			<p class="goods-title">{name}</p>
		</td>
		<td>
			<div class="input-group dazhe">
		       <span class="input-group-addon">打折</span>
		       <input type="text" class="form-control" style="width: 70px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')">
			</div>
		</td>
		<td>
			<div class="input-group jianjia">
				<span class="input-group-addon">减价</span>
				<input type="text" class="form-control" style="width: 70px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')">
			</div>
		</td>
		<td>
			<div class="input-group set_result">
				<span class="input-group-addon">减价后</span>
				<input type="text" class="form-control" style="width: 70px;" readonly="readonly">
			</div>
		</td>
		<td><a id="{id}" href="javascript:void(0)">取消</a></td>
	</tr>	
</script>
<script type="text/template" id="table_noresult_tr_tpl">
	<tr class="package">
			<td class="center" colspan="4">
				没有商品可选择
				<a href="#(webctx)/product/add" style="text-decoration: underline;">去发布商品</a>
			</td>
		</tr>
</script>
<script type="text/javascript" src="#(webctx)/resources/js/promotion/promotion.js"></script>
#end